public class ComparisonOp extends Operator{
	
	public ComparisonOp(String newOp) {
		super(newOp);
	}
	
	@Override
	public boolean isComparisonOp() { 
		return true;
	}
	
	// for lessThanOp, greaterThanOp, lessThanEqualToOp, greaterThanEqualToOp
	@Override
	public STO checkOperands(STO left, STO right) { 
		if (left.isError()) { 
			return left ;
		}
		if (right.isError()){
			return right ;
		}
		STO sto = null;
		Type l_type = left.getType();
		Type r_type = right.getType();
		boolean l_numeric = l_type.isNumeric();
		boolean r_numeric = r_type.isNumeric();
		// both operand types must be numeric, otherwise throw error
		if(l_numeric && r_numeric) {
			if(left.isConst() && right.isConst()) {
				sto = new ConstSTO("Relation result", new BoolType());
			}
			else {
				if(!left.isConst()) {
					sto = new ExprSTO(left.getName(), new BoolType());
				}
				else {
					sto = new ExprSTO(right.getName(), new BoolType());
				}
			}
		}
		else {
			sto = new ErrorSTO("error1n_Expr");
		}
		return sto;
	}
}
